package com.smmisia.shop.controller;

import com.smmisia.common.Result.Result;
import com.smmisia.shop.api.AuthService;
import com.smmisia.shop.api.User;
import com.smmisia.shop.mapper.TicketMapper;
import com.smmisia.shop.request.TicketBuyResponse;
import com.smmisia.shop.request.TicketRequest;
import com.smmisia.shop.response.TicketOrderResponse;
import com.smmisia.shop.response.TicketResponse;
import com.smmisia.shop.service.TicketService;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/ticket")
@Tag(name = "票务管理", description = "票务管理")
public class TicketController {

    @Autowired
    private TicketService ticketService;

    @Autowired
    private AuthService authService;


    /**
     * 根据景区id获取景区票详情
     * @param scenicSpotId
     * @return
     */
    @PostMapping("/getScenicSpotTicket")
    public Result<TicketResponse> getScenicSpotTicket(@RequestParam("scenicSpotId") Integer scenicSpotId){
            return ticketService.getTicketList(scenicSpotId);
    }

    /**
     * 下单景区票
     * @param request
     * @return
     */
    @PostMapping("/buyTicket")
    public Result<TicketBuyResponse> buyTicket(@RequestBody TicketRequest request){
        return ticketService.buyTicket(request);
    }

    /**
     * 下单景区票
     * @param request
     * @return
     */
    @PostMapping("/buyTicketScheduled")
    public Result<Boolean> buyTicketScheduled(@RequestBody TicketRequest request){
        return ticketService.buyTicketScheduled(request);
    }

    /**
     * 获取我的订单
     * @return
     */
    @GetMapping("/getOrderList")
    public Result<List<TicketOrderResponse>> getTicket(){
        return ticketService.getTicket();
    }

    /**
     * 根据id查询订单
     * @return
     */
    @GetMapping("/getOrderById")
    public Result<TicketOrderResponse> getTicketById(@RequestParam Integer orderId){
        return ticketService.getTicketById(orderId);
    }

    /**
     * 取消订单
     * @return
     */
    @GetMapping("/cancel")
    public Result<Boolean> cancelTicketOrder(Integer orderId){
        return ticketService.cancelTicketOrder(orderId);
    }

    /**
     * 支付订单
     * @return
     */
    @GetMapping("/pay")
    public Result<Boolean> payTicketOrder(Integer orderId){
        return ticketService.payTicketOrder(orderId);
    }


}
